{extend name="../../base/view/common/base" /}
<!-- 主体 -->
{block name="body"}
<form class="layui-form p-4">
    <h3 class="pb-3">新办收款详情</h3>

    <table class="layui-table layui-table-form">
        <tr>
            <td colspan="6"><strong>公司信息</strong></td>
        </tr>
        <tr>
            <td class="layui-td-gray-2">公司名称</td>
            <td>{$account_info.company_name}</td>
        </tr>
        <tr >
            <td class="layui-td-gray">开户信息</td>
            <td >
                <input type="checkbox" name="" title="养老" <?php if(in_array('1',$account_info['open_account_type'])){ echo 'checked';}?> value="1" lay-skin="primary">
                <input type="checkbox" name="" title="失业" <?php if(in_array('2',$account_info['open_account_type'])){ echo 'checked';}?> value="2" lay-skin="primary">
                <input type="checkbox" name="" title="工伤" <?php if(in_array('3',$account_info['open_account_type'])){ echo 'checked';}?> value="3" lay-skin="primary">
                <input type="checkbox" name="" title="医疗" <?php if(in_array('4',$account_info['open_account_type'])){ echo 'checked';}?> value="4" lay-skin="primary">
                <input type="checkbox" name="" title="公积金" <?php if(in_array('5',$account_info['open_account_type'])){ echo 'checked';}?> value="5" lay-skin="primary">
            </td>
        </tr>
        <tr>
            <td colspan="6"><strong>客户信息</strong></td>
        </tr>
        <tr>
            <td class="layui-td-gray-2">客户姓名</td>
            <td>{$account_info.client_name}</td>
            <td class="layui-td-gray-2">客户联系电话</td>
            <td>{$account_info.client_mobile}</td>

        </tr>
        <tr>
            <td colspan="6"><strong>签单信息</strong></td>
        </tr>
        <tr>
            <td class="layui-td-gray-2">签单时间</td>
            <td>{$account_info.sign_date}</td>
        </tr>
        <tr>
            <td class="layui-td-gray-2">签单金额</td>
            <td>{$account_info.sign_money}</td>
        </tr>
        <tr id="flow_tr">
            <td class="layui-td-gray">签单人<font>*</font></td>
            <td>{$account_info.sign_name}</td>
        </tr>
        <tr>
            <td class="layui-td-gray-2">提成金额</td>
            <td>{$account_info.deduct}</td>
        </tr>
        <tr>
            <td class="layui-td-gray-2">续费状态</td>
            <td>
                <select lay-reqText="续费状态">
                    <option value="">请选择续费状态</option>
                    <option value="0" <?php if($account_info['renew_state']==0){ echo 'selected';}?>>未续费</option>
                    <option value="1" <?php if($account_info['renew_state']==1){ echo 'selected';}?>>已续费</option>
                </select>
            </td>
            <td class="layui-td-gray-2">签单时长</td>
            <td>{$account_info.renew_length}</td>
        </tr>
        <tr>
            <td class="layui-td-gray-2">到期时间</td>
            <td>{$account_info.expire_date}</td>
        </tr>

        {notempty name="$account_info.licomes"}
        <tr>
            <td colspan="6"><strong>收款信息</strong></td>
        </tr>
        {volist name="$account_info.licomes" id="vo"  key="num"}
        <tr>
            <td class="layui-td-gray-2">第{$num}次收款</td>
            <td>金额:{$vo.money}&nbsp;&nbsp;&nbsp;收款日期:{$vo.money_date}&nbsp;&nbsp;&nbsp;审核状态:<span class="layui-color-{$vo.check_status}">{$vo.status_name}</span>&nbsp;&nbsp;&nbsp;</span>是否结清: {if $vo.account_status eq 1} 已结清 {else/}未结清{/if}</td>
        </tr>
        {/volist}
        {/notempty}
        <tr>
            <td colspan="6"><strong>备注信息</strong></td>
        </tr>
        <tr>
            <td colspan="6">
                {$account_info.remark}
            </td>
        </tr>
        <tr>
            <td colspan="8"><strong>附件</strong></td>
        </tr>

        <tr>
            <td colspan="8" style="line-height:inherit">
                <div class="layui-row" id="fileBox">
                    {notempty name="$account_info.file_ids"}
                    {volist name="$account_info.fileArray" id="vo"}
                    <div class="layui-col-md4" id="uploadImg{$vo.id}">{:file_card($vo)}</div>
                    {/volist}
                    {/notempty}
                </div>
            </td>
        </tr>


        <tr>
            <td colspan="6"><strong>本次收款信息</strong></td>
        </tr>
        <tr>
            <td class="layui-td-gray">本次收款金额</td>
            <td>{$detail.money}</td>
            <td class="layui-td-gray">本次收款日期<font>*</font></td>
            <td>{$detail.money_date}</td>
        </tr>
        <tr>
            <td class="layui-td-gray">本次收款开户行</td>
            <td>{$detail.account_bank}</td>
            <td class="layui-td-gray">本次收款户名</td>
            <td>{$detail.account_name}</td>
        </tr>
        <tr>
            <td class="layui-td-gray">本次收款账号</td>
            <td>{$detail.account_no}</td>
        </tr>
        <tr>
            <td class="layui-td-gray">本次收款是否已结清</td>
            <td>
                {if  $detail.account_status eq 1}
                已结清
                {else/}
                未结清
                {/if}
            </td>
        </tr>
        {if  $detail.account_status eq 1}
        <tr>
            <td colspan="6"><strong>签单提成信息</strong></td>
        </tr>
        <tr id="flow_tr">
            <td class="layui-td-gray-2">签单人<font>*</font></td>
            <td>{$account_info.sign_name}</td>
        </tr>
        <tr>
            <td class="layui-td-gray-2">签单金额</td>
            <td>{$account_info.sign_money}</td>

        </tr>
        <tr>
            <td class="layui-td-gray-2">签单提成</td>
            <td>{$account_info.deduct}</td>
        </tr>
        {/if}
        <tr>
            <td colspan="6"><strong>本次收款备注</strong></td>
        </tr>
        <tr>
            <td colspan="6">{$detail.remark}</td>
        </tr>
        <tr>
            <td colspan="6"><strong>本次收款附件</strong></td>
        </tr>
        <tr>
            <td colspan="6"><strong>附件</strong></td>
        </tr>
        <tr>
            <td colspan="5" style="line-height:inherit">
                <div class="layui-row" id="fileBox">
                    {notempty name="$detail.file_ids"}
                    {volist name="$detail.fileArray" id="vo"}
                    <div class="layui-col-md4" id="uploadImg{$vo.id}">{:file_card($vo)}</div>
                    {/volist}
                    {/notempty}
                </div>
            </td>
        </tr>
        <tr>
            <td colspan="8"><strong>收款审核信息</strong></td>
        </tr>
        <tr>
            <td class="layui-td-gray-2">审核状态</td>
            <td><span class="layui-color-{$detail.check_status}">{$detail.status_name}</span></td>
            <td class="layui-td-gray-2">录入人</td>
            <td>{$detail.create_user|default=''}</td>
            <td class="layui-td-gray-2">录入时间</td>
            <td colspan="3">{$detail.create_time|default=''}</td>
        </tr>
        {notempty name="$check_record"}
        <tr>
            <td class="layui-td-gray">审批记录</td>
            <td colspan="5">
                <ul class="layui-timeline flow-record pt-2">
                    {volist name="$check_record" id="vo"}
                    <li class="layui-timeline-item delete-{$vo.delete_time}">
                        <i class="layui-icon layui-timeline-axis">&#xe63f;</i>
                        <p style="padding-left:24px">{$vo.check_time_str}<span class="black ml-2">{$vo.name}</span><span
                                class="mx-2 layui-color-{$vo.status}">{$vo.status_str}</span>了此申请。操作意见：<span
                                class="green">{$vo.content}</span></p>
                    </li>
                    {/volist}
                </ul>
            </td>
        </tr>
        {/notempty}
        {if ( $detail.check_status eq 1) AND ( $is_check_admin eq 1) }
        {eq name="$flows.flow_type" value="0"}
        <tr>
            <td class="layui-td-gray">审批节点 <font>*</font></td>
            <td colspan="5">
                <form class="layui-form">
                    <input type="radio" name="check_node" lay-filter="check_node" value="1" title="审核结束">
                    <input type="radio" name="check_node" lay-filter="check_node" value="2" title="下一审批人">
                    <div class="layui-inline">
                        <input type="text" name="check_admin_name" value="" autocomplete="off" placeholder="请选择下一审批人"
                               lay-verify="required" lay-reqText="请选择下一审批人" class="layui-input picker-one"><input
                            type="hidden" name="check_admin_ids" value="">
                    </div>
                </form>
            </td>
        </tr>
        {/eq}
        <tr>
            <td class="layui-td-gray">审批意见 <font>*</font></td>
            <td colspan="5">
                <textarea name="content" placeholder="请输入审批意见" class="layui-textarea"></textarea>
            </td>
        </tr>
        {/if}
    </table>
    <input type="hidden" name="id" value="{$detail.id}">
    <input type="hidden" name="flow_type" value="{$flows.flow_type}">
    <input type="hidden" name="check_step_sort" value="{$detail.check_step_sort}">
    <input type="hidden" name="check_status" value="{$detail.check_status}">
    <div id="formBtn" style="padding: 10px 0">
        {eq name="$detail.check_status" value='1'}
        {eq name="$is_check_admin" value='1'}
        <span class="layui-btn layui-btn-normal" data-status="1"><i class="layui-icon layui-icon-ok"></i> 通过</span>
        <span class="layui-btn layui-btn-danger" data-status="2"><i class="layui-icon layui-icon-close"></i> {$flows.flow_type == 5?'回退':'拒绝'}</span>
        {/eq}
        {eq name="$is_create_admin" value='1'}
        <span class="layui-btn layui-btn-primary" data-status="3"><i class="layui-icon layui-icon-reduce-circle"></i> 撤回</span>
        {/eq}
        {/eq}
        {if ( $detail.check_status eq 3) AND ( $is_create_admin eq 1) }
        <span class="layui-btn layui-btn-primary" data-status="3"><i class="layui-icon layui-icon-reduce-circle"></i> 撤回</span>
        {/if}

    </div>
    </table>
</form>
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script>
    const moduleInit = ['tool','employeepicker','oaTool'];
    function gouguInit() {
        var form = layui.form,tool=layui.tool, oaTool = layui.oaTool,dropdown = layui.dropdown;
        //获取审核信息
        $.ajax({
            url: "/api/index/get_flow_nodes",
            type:'get',
            data:{id:$('[name="id"]').val(),type:17},
            success: function (e) {
                if (e.code == 0) {
                    let flowHtml='',list = e.data,record_list='',sort = $('[name="check_step_sort"]').val(), check_status = $('[name="check_status"').val();
                    for(var f=0;f<list.length;f++){
                        //审批流程
                        let checkUser = '',
                            iconRight ='<span class="layui-icon layui-icon-right"></span>',
                            iconStatus ='<i class="layui-icon layui-icon-time"></i>',
                            strStatus ='<div class="check-item-status">待审核</div>',
                            sortClass ='';
                        if(f == list.length-1){
                            iconRight ='';
                        }
                        if(list[f].flow_type == 1 || list[f].flow_type == 2){
                            checkUser=list[f].flow_type == 1?'部门负责人':'上级部门负责人';
                            if(list[f].check_list.length>0){
                                if(list[f].check_list[0].status == 1){
                                    iconStatus ='<i class="layui-icon layui-icon-ok-circle" data-ok=""></i>';
                                    strStatus ='<div class="check-item-status">通过</div>';
                                }
                                else if(list[f].check_list[0].status == 2){
                                    iconStatus ='<i class="layui-icon layui-icon-close" data-no=""></i>';
                                    strStatus ='<div class="check-item-status">拒绝</div>';
                                }
                            }
                        }
                        else if(list[f].flow_type == 0 ){
                            checkUser=list[f].user_id_info[0].name;
                            if(list[f].check_list.length>0){
                                iconStatus ='<i class="layui-icon layui-icon-close" data-no=""></i>';
                                strStatus ='<div class="check-item-status">拒绝</div>';
                                for(var m=0;m<list[f].check_list.length;m++){
                                    if(list[f].check_list[m].status == 1){
                                        iconStatus ='<i class="layui-icon layui-icon-ok-circle" data-ok=""></i>';
                                        strStatus ='<div class="check-item-status">通过</div>';
                                    }
                                }
                            }
                        }
                        else if(list[f].flow_type == 3 ){
                            checkUser='多人或签';
                            if(list[f].user_id_info.length>0){
                                iconStatus ='<i class="layui-icon layui-icon-time"></i>';
                                strStatus ='<div class="check-item-status">待审核</div>';
                                for(var m=0;m<list[f].user_id_info.length;m++){
                                    if(list[f].user_id_info[m].status == 1){
                                        iconStatus ='<i class="layui-icon layui-icon-ok-circle" data-ok=""></i>';
                                        strStatus ='<div class="check-item-status">通过</div>';
                                        break;
                                    }
                                    if(list[f].user_id_info[m].status == 2){
                                        iconStatus ='<i class="layui-icon layui-icon-close" data-no=""></i>';
                                        strStatus ='<div class="check-item-status">拒绝</div>';
                                    }
                                }
                            }
                        }
                        else if(list[f].flow_type == 4){
                            checkUser='多人会签';
                            if(list[f].user_id_info.length>0){
                                iconStatus ='<i class="layui-icon layui-icon-ok-circle" data-ok=""></i>';
                                strStatus ='<div class="check-item-status">通过</div>';
                                for(var m=0;m<list[f].user_id_info.length;m++){
                                    if(list[f].user_id_info[m].status == 2){
                                        iconStatus ='<i class="layui-icon layui-icon-close" data-no=""></i>';
                                        strStatus ='<div class="check-item-status">拒绝</div>';
                                        break;
                                    }
                                    if(list[f].user_id_info[m].status == 0){
                                        iconStatus ='<i class="layui-icon layui-icon-time"></i>';
                                        strStatus ='<div class="check-item-status">待审核</div>';
                                    }
                                }
                            }
                        }
                        else if(list[f].flow_type == 5){
                            checkUser=list[f].flow_name+' ['+list[f].user_id_info[0].name+']';
                            if(list[f].user_id_info.length>0){
                                iconStatus ='<i class="layui-icon layui-icon-ok-circle" data-ok=""></i>';
                                strStatus ='<div class="check-item-status">通过</div>';
                                for(var m=0;m<list[f].user_id_info.length;m++){
                                    if(list[f].user_id_info[m].status == 2){
                                        iconStatus ='<i class="layui-icon layui-icon-close" data-no=""></i>';
                                        strStatus ='<div class="check-item-status">拒绝</div>';
                                        break;
                                    }
                                    if(list[f].user_id_info[m].status == 0){
                                        iconStatus ='<i class="layui-icon layui-icon-time"></i>';
                                        strStatus ='<div class="check-item-status">待审核</div>';
                                    }
                                }
                            }
                        }

                        if(sort == list[f].sort && check_status==1){
                            sortClass ='flow-this';
                            iconStatus ='<i class="layui-icon layui-icon-time"></i>';
                            strStatus ='<div class="check-item-status">当前审核</div>';
                        }
                        flowHtml+= '<div class="flow-flexbox check-item flow-flex-row '+sortClass+'" id="flow'+f+'">'+iconStatus+'\
							<div class="check-item-name">'+checkUser+'</div>'+strStatus+iconRight+'\
						</div>';
                    }

                    $('#flowList').append(flowHtml);

                    for(var f=0;f<list.length;f++){
                        if(list[f].flow_type == 3 || list[f].flow_type == 4){
                            var user_list= '';
                            for(var a=0;a<list[f].user_id_info.length;a++){
                                if(list[f].user_id_info[a].status==0){
                                    user_list+='<li><i class="layui-icon layui-icon-time"></i> '+list[f].user_id_info[a].name+'<span>待审核此申请</span></li>';
                                }
                                else if(list[f].user_id_info[a].status==1){
                                    user_list+='<li><i class="layui-icon layui-icon-ok-circle" data-ok=""></i><span>'+list[f].user_id_info[a].check_time+'</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+list[f].user_id_info[a].name+'<span>已通过此申请</span></li>';
                                }else if(list[f].user_id_info[a].status==2){
                                    user_list+='<li><i class="layui-icon layui-icon-close" data-no=""></i><span>'+list[f].user_id_info[a].check_time+'</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+list[f].user_id_info[a].name+'<span>已拒绝此申请</span></li>';
                                }
                            }
                            dropdown.render({
                                elem: '#flow'+f
                                ,trigger: 'hover'
                                ,content: ['<div class="flow-tips">'
                                    ,'<ul>'+user_list+'</ul>'
                                    ,'</div>'].join('')
                            });
                        }
                    }
                }
            }
        })

        //监听提交
        $('#formBtn').on('click','span', function(data){
            let id=$('[name="id"]').val();
            let content=$('[name="content"]').val();
            let check_status=$(this).data('status');

            let flow_type = $('input[name="flow_type"]').val();
            let check_node=0,check_admin_ids=0;
            if(flow_type == 0 && check_status==1){
                check_node = $('input[name="check_node"]:checked').val();
                check_admin_ids = $('input[name="check_admin_ids"]').val();
                if(!check_node){
                    layer.msg('请选择下一审批节点');
                    return false;
                }
                if(check_node == 2 && check_admin_ids==''){
                    layer.msg('请选择下一审批人');
                    return false;
                }
            }

            if(check_status ==1 || check_status==2){
                if(content==''){
                    layer.msg('请输入审批意见');
                    return false;
                }
                let confirmTips='确定通过该审核？';
                if(check_status==2){
                    confirmTips='确定拒绝该审核？';
                }
                layer.confirm(confirmTips, function(index){
                    $.ajax({
                        url: "/api/index/flow_check",
                        type:'post',
                        data:{
                            id:id,
                            type:17,
                            check_node:check_node,
                            check_admin_ids:check_admin_ids,
                            check:check_status,
                            content:content
                        },
                        success: function (e) {
                            layer.msg(e.msg);
                            if (e.code == 0) {
                                tool.sideClose(1000);
                            }
                        }
                    })
                    layer.close(index);
                });
            }
            else if(check_status == 3){
                layer.prompt({
                    formType: 2,
                    title: '请输入撤回理由',
                    area: ['500px', '120px'] //自定义文本域宽高
                }, function(value, index, elem){
                    if(value==''){
                        layer.msg('请输入撤回理由');
                        return false;
                    }
                    $.ajax({
                        url: "/api/index/flow_check",
                        type:'post',
                        data:{
                            id:id,
                            type:17,
                            check:check_status,
                            content:value
                        },
                        success: function (e) {
                            layer.msg(e.msg);
                            if (e.code == 0) {
                                tool.sideClose(1000);
                            }
                        }
                    })
                    layer.close(index);
                });
            }
            return false;
        });
    }
</script>
{/block}
<!-- /脚本 -->